1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */ 
28 
29 module derelict.purple.cmds;
30 
31 import derelict.glib.gtypes;
32 import derelict.glib.glibconfig;
33 import derelict.glib.glist;
34 import derelict.purple.conversation;
35 extern (C):
36 
37 alias _PurpleCmdStatus PurpleCmdStatus;
38 alias _PurpleCmdRet PurpleCmdRet;
39 alias _PurpleCmdRet function (_PurpleConversation*, const(char)*, char**, char**, void*) PurpleCmdFunc;
40 alias uint PurpleCmdId;
41 alias _PurpleCmdPriority PurpleCmdPriority;
42 alias _PurpleCmdFlag PurpleCmdFlag;
43 
44 enum _PurpleCmdStatus
45 {
46 	PURPLE_CMD_STATUS_OK = 0,
47 	PURPLE_CMD_STATUS_FAILED = 1,
48 	PURPLE_CMD_STATUS_NOT_FOUND = 2,
49 	PURPLE_CMD_STATUS_WRONG_ARGS = 3,
50 	PURPLE_CMD_STATUS_WRONG_PRPL = 4,
51 	PURPLE_CMD_STATUS_WRONG_TYPE = 5
52 }
53 
54 enum _PurpleCmdRet
55 {
56 	PURPLE_CMD_RET_OK = 0,
57 	PURPLE_CMD_RET_FAILED = 1,
58 	PURPLE_CMD_RET_CONTINUE = 2
59 }
60 
61 enum _PurpleCmdPriority
62 {
63 	PURPLE_CMD_P_VERY_LOW = -1000,
64 	PURPLE_CMD_P_LOW = 0,
65 	PURPLE_CMD_P_DEFAULT = 1000,
66 	PURPLE_CMD_P_PRPL = 2000,
67 	PURPLE_CMD_P_PLUGIN = 3000,
68 	PURPLE_CMD_P_ALIAS = 4000,
69 	PURPLE_CMD_P_HIGH = 5000,
70 	PURPLE_CMD_P_VERY_HIGH = 6000
71 }
72 
73 enum _PurpleCmdFlag
74 {
75 	PURPLE_CMD_FLAG_IM = 1,
76 	PURPLE_CMD_FLAG_CHAT = 2,
77 	PURPLE_CMD_FLAG_PRPL_ONLY = 4,
78 	PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS = 8
79 }
80 
81 version(Derelict_Link_Static)
82 {
83     extern( C ) nothrow 
84     {
85 	    PurpleCmdId purple_cmd_register(const(gchar)* cmd, const(gchar)* args, PurpleCmdPriority p, PurpleCmdFlag f, const(gchar)* prpl_id, PurpleCmdFunc func, const(gchar)* helpstr, void* data);
86         void purple_cmd_unregister(PurpleCmdId id);
87         PurpleCmdStatus purple_cmd_do_command(PurpleConversation* conv, const(gchar)* cmdline, const(gchar)* markup, gchar** errormsg);
88         GList* purple_cmd_list(PurpleConversation* conv);
89         GList* purple_cmd_help(PurpleConversation* conv, const(gchar)* cmd);
90         gpointer purple_cmds_get_handle();
91         void purple_cmds_init();
92         void purple_cmds_uninit();
93     }
94 }
95 else
96 {
97     extern( C ) nothrow 
98     {
99 	    alias da_purple_cmd_register = PurpleCmdId function(const(gchar)* cmd, const(gchar)* args, PurpleCmdPriority p, PurpleCmdFlag f, const(gchar)* prpl_id, PurpleCmdFunc func, const(gchar)* helpstr, void* data);	
100         alias da_purple_cmd_unregister = void function(PurpleCmdId id);																																					
101         alias da_purple_cmd_do_command = PurpleCmdStatus function(PurpleConversation* conv, const(gchar)* cmdline, const(gchar)* markup, gchar** errormsg);																
102         alias da_purple_cmd_list = GList* function(PurpleConversation* conv);																																			
103         alias da_purple_cmd_help = GList* function(PurpleConversation* conv, const(gchar)* cmd);																														
104         alias da_purple_cmds_get_handle = gpointer function();																																							
105         alias da_purple_cmds_init = void function();																																									
106         alias da_purple_cmds_uninit = void function();																																									
107     }
108 
109     __gshared
110     {
111 	    da_purple_cmd_register purple_cmd_register;
112 	    da_purple_cmd_unregister purple_cmd_unregister;
113 	    da_purple_cmd_do_command purple_cmd_do_command;
114 	    da_purple_cmd_list purple_cmd_list;
115 	    da_purple_cmd_help purple_cmd_help;
116 	    da_purple_cmds_get_handle purple_cmds_get_handle;
117 	    da_purple_cmds_init purple_cmds_init;
118 	    da_purple_cmds_uninit purple_cmds_uninit;
119     }
120 }